<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">

<head>
	<meta charset="UTF-8">
	<title></title>
	<link rel="stylesheet" href="/res/css/amazeui.min.css" />
	<link rel="stylesheet" href="/res/css/admin.css" />
</head>

<body>
<div class="admin-content-body">
	<div class="am-cf am-padding am-padding-bottom-0">
		<div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">问卷列表</strong><small></small></div>
	</div>

	<hr>

	<div class="am-g">
		<div class="am-u-sm-12 am-u-md-6">
			<div class="am-btn-toolbar">
				<div class="am-btn-group am-btn-group-xs">
					<button type="button" class="am-btn am-btn-default" onclick="window.location.href='/question_add'"><span class="am-icon-plus"></span> 新增</button>
				</div>
			</div>
		</div>
		<div class="am-u-sm-12 am-u-md-3">

		</div>
		<div class="am-u-sm-12 am-u-md-3">
			<form action="/questionnaire/view/search" method="get">
			<div class="am-input-group am-input-group-sm">
				<input type="text" name="key" class="am-form-field" placeholder="请输入问卷名称" />
				<span class="am-input-group-btn">
            <button class="am-btn am-btn-default" type="submit">搜索</button>
          </span>
			</div>
			</form>
		</div>
	</div>
	<div class="am-g">
		<div class="am-u-sm-12">
			<form class="am-form">
				<table class="am-table am-table-striped am-table-hover table-main">
					<thead>
					<tr>
						<th class="table-title">名称</th>
						<th class="table-type">类型</th>
						<th class="table-author am-hide-sm-only">结束时间</th>
						<th class="table-author am-hide-sm-only">创建时间</th>
						<th class="table-author am-hide-sm-only">更新时间</th>
						<th class="table-set">操作</th>
					</tr>
					</thead>
					<tbody>
					<tr th:each="item : ${ list }">
						<td th:text="${item.name}"></td>
						<td th:text="${item.type}"></td>
						<td th:text="${#dates.format(item.endTime, 'yyyy-MM-dd')}"></td>
						<td th:text="${#dates.format(item.createTime, 'yyyy-MM-dd HH:mm:ss')}"></td>
						<td th:text="${#dates.format(item.updateTime, 'yyyy-MM-dd HH:mm:ss')}"></td>
						<td>
							<div class="am-btn-toolbar">
								<div class="am-btn-group am-btn-group-xs">
									<a class="am-btn am-btn-default am-btn-xs am-text-secondary" th:href="${'/questionnaire/add_subject?id='+item.id}"><span class="am-icon-pencil-square-o"></span> 编辑</a>
									<button class="btn-danger" th:onclick="del([[${item.id}]])" ><span class="am-icon-trash-o"></span> 删除</button>
								</div>
							</div>
						</td>
					</tr>

					</tbody>
				</table>
				<div class="am-cf">
					共 <span th:text="${total}"></span> 条记录
					<div class="am-fr">
						<ul class="am-pagination" th:if="${pages>1}">
							<li><a th:href="${ pageNum-1<1 ? '/questionnaire/view/list?pageNum='+1 : '/questionnaire/view/list?pageNum='+ (pageNum-1) }">&laquo;</a></li>
							<li th:each="i : ${ #numbers.sequence(1,pages) }" th:class="${ i==pageNum ? 'am-active':'' }"><a th:href="${'/questionnaire/view/list?pageNum='+i}" th:text="${i}"></a></li>
							<li><a th:href="${ pageNum+1 > total ? '/questionnaire/view/list?pageNum=' + total : '/questionnaire/view/list?pageNum=' + (pageNum+1) }">&raquo;</a></li>
						</ul>
					</div>
				</div>
				<hr>
			</form>
		</div>
	</div>
</div>
</body>
<script>
    function del(id) {
        if(confirm("是否确认删除？")){
            window.location.href = '/questionnaire/pc/del?id='+id;
            window.event.returnValue=false;
        }else {
            alert("已取消删除");
        }
    }
</script>
</html>